<template>
  <a-modal title='请选择流程退回节点' width='600px' :visible.sync='dialogTaskBackNodesInChild' @cancel='handleCancel' @ok='handlerSubmit'>
    <a-radio-group v-model='backNode' @change='selectBackNode'>
      <a-radio v-for='(item,index) in backNodes' :value='item' :key='index'>
        {{ item.nodeName }} {{ item.userName }}
      </a-radio>

    </a-radio-group>
    <br /><br />
    <a-input-group compact>
      <a-input style='width: 60%' v-model='message' />
      <a-select style='width: 35%' @change='messageChange' placeholder='常用语选择'>
        <a-select-option value='退回'>
          退回
        </a-select-option>
        <a-select-option value='业务编码错误'>
          业务编码错误
        </a-select-option>
        <a-select-option value='发货方式错误'>
          发货方式错误
        </a-select-option>
        <a-select-option value='认款信息错误'>
          认款信息错误
        </a-select-option>
        <a-select-option value='商品信息错误'>
          商品信息错误
        </a-select-option>
      </a-select>
    </a-input-group>


  </a-modal>
</template>

<script>
import api from "../js/api"

export default {
  name: "TaskbackModel",
  props: {
    visible: {
      type: Boolean,
      default: function() {
        return false
      }
    },
    executeTaskId: {
      type: String,
      default: function() {
        return ""
      }
    }
  },
  computed: {
    dialogTaskBackNodesInChild: {
      get() {
        return this.visible
      },
      set(val) {
        this.$emit("update:visible", val)
      }
    }
  },
  data() {
    return {
      api: Object.assign(api, this.api),
      backNode: {},
      message: "退回",
      backNodes: []
    }
  },
  created() {
    this.initData()
  },
  methods: {
    messageChange(value) {
      this.message = value
      this.$forceUpdate()
    },
    handleCancel() {
      this.dialogTaskBackNodesInChild = false
    },
    initData() {
      this.http.get(this, {
        url: this.api.tasktodo.getBackNodes,
        params: {
          taskId: this.executeTaskId
        },
        success: function(me, data) {
          me.backNodes = [data[data.length-1]]
          me.backNode = me.backNodes[0]
        }
      })
    },
    selectBackNode(e) {
      this.backNode = e.target.value
    },
    handlerSubmit() {
      this.dialogTaskBackNodesInChild = false
      this.$emit("backTaskSubmit", this.backNode, this.message)
    }
  }
}
</script>

